package com.mshop.admin;

import java.util.List;

import com.mshop.fw.modules.SM;
import com.mshop.po.Jiangpin;
import com.mshop.po.Manager;
import com.mshop.util.CONSTANTS;
import com.mshop.util.WebContext;

/**
 * 
 * 
 * Title:
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2008
 * 
 * @author haoxz11
 * @created Oct 21, 2008 11:16:42 AM
 * @version $Id: SysMenuAction.java,v 1.1 2010/04/09 03:27:09 airsou Exp $
 */
public class JiangpinAction extends WebAction {
	private String method;
	private String id;
	private Jiangpin jiangpin;



	/**
	 * @return the Jiangpin
	 */
	public Jiangpin getJiangpin() {
		return jiangpin;
	}

	/**
	 * @param jiangpin the jiangpin to set
	 */
	public void setJiangpin(Jiangpin jiangpin) {
		this.jiangpin = jiangpin;
	}

	/**
	 * @return the method
	 */
	public String getMethod() {
		return method;
	}

	/**
	 * @param method
	 *            the method to set
	 */
	public void setMethod(String method) {
		this.method = method;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String webProcess(WebContext context, Manager manager) {
		if ("add".equals(method)) {
			return "edit";
		} else if ("edit".equals(method)) {
			Jiangpin jiangpin = SM.JiangpinService.get(id);
			context.put("jiangpin", jiangpin);
			return "edit";
		} else if ("save".equals(method)) {
			SM.JiangpinService.save(jiangpin);
			context.put("rmsg", CONSTANTS.TEXT.SAVE_SUCCESS);
			return "save";
		}else if ("delete".equals(method)) {
			SM.JiangpinService.delete(id);
			context.put("rmsg", CONSTANTS.TEXT.DELETE_SUCCESS);
			return "delete";
		}else if ("list".equals(method)) {
			List<Jiangpin> jiangpinList = SM.JiangpinService.list();
			context.put("jiangpinList", jiangpinList);
			return "list";
		} else {
			method = "list";
			return this.webProcess(context, manager);
		}
	}

	/* (non-Javadoc)
	 * @see com.camel.admin.WebAction#getSysLog()
	 */
	@Override
	public String getSysLog() {
		return null;
	}
}
